package main

import "fmt"

func main(){

	s:= "这是一个不重复的文字。。"

	num := Nonrepeating(s)

	fmt.Println(num)

}

var lastOcurred = make([]int,0xffff)

func Nonrepeating(s string) int{
	start := 0
	maxLength := 0
	for i:= range lastOcurred{
		lastOcurred[i] = -1
	}
	for k,v:= range []rune(s){
		if lastId := lastOcurred[v]; lastId!= -1 && lastId >= start{
			start = lastId+1
		}
		if k-start+1 >maxLength{
			maxLength = k-start+1
		}
		lastOcurred[v] = k
	}
	return maxLength
}